<div class="page page-table" data-ng-controller="excelExport">
    <section class="panel panel-default table-dynamic">
        <div class="panel-heading"><strong><span class="glyphicon glyphicon-th"></span>&nbsp;&nbsp;&nbsp;&nbsp;导出数据列表</strong></div>
        <div class="table-filters">
            <div class="form-group has-error has-feedback input-lg" style="height:30px;text-align: center;"><label
                    id="errorShow" class="control-label"></label><input type="hidden" id="errorHide"/></div>
            <form role="form" action="management/interview/exportExcel" onsubmit="return checkDate()" method="post">
                <div class="row">
                    <div  class="col-sm-4">
                        <div class="input-group ui-datepicker" data-ng-controller="DatepickerDemoCtrl">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i>&nbsp;&nbsp;开始</span>
                            <input type="text"
                                   id="startDate" name="startDate"
                                   class="form-control"
                                   datepicker-popup="yyyy-MM-dd"
                                   ng-model="dt" is-open="opened"
                                   datepicker-options="dateOptions"
                                   ng-required="true"
                                   close-text="关闭">
                        </div>
                    </div>
                    <div id="endDiv" class="col-sm-4">
                        <div class="input-group ui-datepicker" data-ng-controller="DatepickerDemoCtrl">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i>&nbsp;&nbsp;结束</span>
                            <input type="text"
                                   id="endDate" name="endDate"
                                   class="form-control"
                                   datepicker-popup="yyyy-MM-dd"
                                   ng-model="dt" is-open="opened"
                                   datepicker-options="dateOptions"
                                   ng-required="true"
                                   close-text="关闭">
                        </div>
                    </div>
                    <div class="col-sm-1"><a class="btn btn-primary" onclick="checkDate();" data-ng-click="showDate()">查询</a></div>
                    <div class="col-sm-1"><button class="btn btn-info">导出</button></div>
                    <div class="col-sm-3" data-ng-show="userPerHide">
                        <br/>
                        <select id="selectUser" data-ng-model="userId" data-ng-change="showDate()" name="userId" class="col-sm-12"
                                style="font-size: 15px;height: 35px;" onchange="checkDate()">
                            <option value=""></option>
                            <option data-ng-repeat="user in userInfo" value="{{user.id}}">{{user.realname}}</option>
                        </select>
                        <input id="selectUserName" name="userName" type="hidden"/>
                    </div>
                </div>
            </form>
        </div>
        <table class="table table-bordered table-striped table-responsive">
            <thead>
            <tr>
                <th style="width:140px;"><div class="th">
                    录入时间
                </div></th><th><div class="th">
                    姓名
                </div></th><th><div class="th">
                    电话
                </div></th><th><div class="th">
                    学历
                </div></th><th><div class="th">
                    来源
                </div></th><th><div class="th">
                    咨询师
                </div></th><th style="width:140px;"><div class="th">
                    最近联系
                </div></th><th><div class="th">
                    情况
                </div></th><th><div class="th">
                    备注
                </div></th>
            </tr>
            </thead>
            <tbody>
            <tr data-ng-repeat="info in phones">
                <td>{{info.createTime | dataFormat}}</td>
                <td>{{info.realName}}</td>
                <td>{{info.phoneNum}}</td>
                <td>{{info.eduName}}</td>
                <td>{{info.sourceName}}</td>
                <td>{{info.userName}}</td>
                <td>{{info.visitTime | dataFormat}}</td>
                <td>{{info.sitName}}</td>
                <td>{{info.note}}</td>
            </tr>
            </tbody>
        </table>
    </section>
</div>
<script type="text/javascript">
    function checkDate(){
        $("#selectUserName").val($("#selectUser").find("option:selected").text());
        if($("#startDate").val().length == 0 ||$("#endDate").val().length == 0){
            $("#errorShow").html('开始时间和结束时间都不能为空');
            $("#errorHide").val("true");setTimeout(function(){$("#errorShow").html("")},5000);return false;
        }
        var startDate = new Date($("#startDate").val());var endDate = new Date($("#endDate").val());
        var dateCha = (endDate.getTime()-startDate.getTime());
        if(dateCha < 0 || dateCha>(1000*60*60*24*30)){$("#errorShow").html('开始时间要小于结束时间且间距为一个月');
            $("#errorHide").val("true");setTimeout(function(){$("#errorShow").html("")},5000);return false;}
        $("#errorShow").html('');$("#errorHide").val("");
        return true;
    }
</script>
